<template>
  <div>
    <el-dialog width="80%" top="1vh" title="查看风控大数据" :visible.sync="dialogVisible" :close-on-click-modal="true">
      <h2>{{ initData.cert_name }}风控大数据报告</h2>
      <br>
      <el-row>
        <el-col :span="8">报告生成时间：{{ initData.start_at }}</el-col>
        <el-col :span="8">有效期至：{{ initData.end_at }}</el-col>
        <el-col :span="8">订单ID：{{ initData.orderId }}</el-col>
      </el-row>
      <br>
      <p class="red">报告生成可能有延迟，请确认报告成功生成</p>
      <br>
      <h3>风险建议：{{ initData.resp_data.verify_recomment }}</h3>
      <br>
      <h3>信贷洞察分值：{{ initData.resp_data.score_norm_explain }}
        <el-progress :text-inside="true" :stroke-width="20"
              :percentage="initData.resp_data.score_norm_explain==null?'0':parseFloat(initData.resp_data.score_norm_explain).toFixed(2)" status="success">
            </el-progress>
      </h3> 
      <br>
      <el-descriptions title="基本数据" direction="vertical" :column="5" border>
        <el-descriptions-item label="姓名">{{ initData.cert_name }}</el-descriptions-item>
        <el-descriptions-item label="性别">{{ Object.keys(this.initData.resp_data).length ?
            initData.resp_data.base_info.gender : ''
        }}</el-descriptions-item>
        <el-descriptions-item label="年龄">
          {{ Object.keys(this.initData.resp_data).length ? initData.resp_data.base_info.age : '' }}
        </el-descriptions-item>
        <el-descriptions-item label="手机号码">{{ Object.keys(this.initData.resp_data).length ?
            initData.resp_data.base_info.phone : ''
        }}</el-descriptions-item>
        <el-descriptions-item label="手机号码归属地">{{ Object.keys(this.initData.resp_data).length ?
            initData.resp_data.base_info.phone_address : ''
        }}</el-descriptions-item>
        <el-descriptions-item label="身份证号码" :span="2">{{ Object.keys(this.initData.resp_data).length ?
            initData.resp_data.base_info.ident_number : ''
        }}</el-descriptions-item>
        <el-descriptions-item label="身份证号地址">{{ Object.keys(this.initData.resp_data).length ?
            initData.resp_data.base_info.ident_number_address : ''
        }}</el-descriptions-item>
      </el-descriptions>
      <br>
      <br>
      <el-descriptions title="运营商信息" direction="vertical" :column="5" border>
        <el-descriptions-item label="二要素认证">{{一致}}</el-descriptions-item>
        <el-descriptions-item label="三要素认证">{{一致}}</el-descriptions-item>
        <el-descriptions-item label="手机在网时长">{{ '[1-3)' }}</el-descriptions-item>
        <el-descriptions-item label="在网状态">{{ 正常 }}</el-descriptions-item>
        <el-descriptions-item label="近三月流量均值">{{ '(0-100]' }}</el-descriptions-item>
        <el-descriptions-item label="近3个月总停机次数">{{ '(0-100]' }}</el-descriptions-item>
        <el-descriptions-item label="近3个月通话时长均值">{{ '电信-(300,500]' }}</el-descriptions-item>
        <el-descriptions-item label="近3个月平均月账单金额">{{ '移动-[200,300)'}}</el-descriptions-item>
        <el-descriptions-item label="运营商归属信息">{{ '(0-100]' }}</el-descriptions-item>
      </el-descriptions>
      <br>
      <el-descriptions title="押金建议" direction="vertical" :column="6" border>
        <el-descriptions-item label="押金建议"></el-descriptions-item>
        <el-descriptions-item label="产品类别"></el-descriptions-item>
        <el-descriptions-item label="新旧程度"></el-descriptions-item>
        <el-descriptions-item label="总租金"></el-descriptions-item>
        <el-descriptions-item label="总期数"></el-descriptions-item>
        <el-descriptions-item label="官方售价"></el-descriptions-item>
      </el-descriptions>
      
      <br>

      <br>
      <br>
    </el-dialog>
  </div>

</template>

<script>
import { getRiskData } from "@/api/order";
export default {
  props: ['editItem'],
  data() {
    return {
      form: {
        orderId: '',
        cert_name: '', //真实姓名
        cert_no: '', //身份证号
        mobile: '', //手机号
        rent_total: '',
        month_total: '',
        website_price: '',
        new_grade: '',
        goods_type: ''
      },
      initData: {
        cert_name: '',
        cert_no: '',
        mobile: '',
        resp_data: {},
        start_at: '',
        end_at: '',
        orderId: '',
        level: '', //还款能力等级
        ability: ''  //还款能力稳定性
      },
      respData: {},
      court_risk_info_list: [], //法院
      personal_overdue_history_list: [], //历史逾期记录
      hit_risk_tagging: [],//命中风险标记
      dialogVisible: false
    }
  },
  methods: {
    getTimes(item){
      if(item==1){
        return '3个月'
      }else if(item==2){
        return '3-6个月'
      }else if(item==3){
        return '6-12个月'
      }else if(item==4){
        return '12-24个月'
      }else if(item==5){
        return '24个月以上'
      }else if(item==0){
        return '查无记录'
      }else {
        return '不⽀持该运营商'
      }
    },
    getData() {
      this.initData.cert_name = this.form.cert_name
      this.initData.cert_no = this.form.cert_no
      this.initData.mobile = this.form.mobile
      getRiskData(this.form).then(res => {
        this.initData.resp_data = res.resp_data
        this.initData.start_at = res.start_at
        this.initData.end_at = res.end_at
        this.initData.orderId = res.order_id
        this.initData.level = res.level
        this.initData.ability = res.ability
        this.court_risk_info_list = res.resp_data.court_risk_info_list
        this.personal_overdue_history_list = Object.keys(res.resp_data.personal_overdue_history.datalist).length ? res.resp_data.personal_overdue_history.datalist : []
        this.hit_risk_tagging = res.resp_data.hit_risk_tagging
        console.log(res)
      })
    },
    init() {
      for (let key in this.form) {
        // this.form[key] = this.editItem[key].toString() || ''
        this.form[key] = this.editItem[key]
      }
    }

  },
  watch: {
    dialogVisible(val) {
      if (val) {
        this.init()
        this.getData()
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.type_tip {
  color: #999999;
  line-height: 22px;

  span {
    color: #ff4146;
  }
}
</style>
